

function initSlider() {
  new Swiper(".swiper", {
    autoplay: false,//可选选项，自动滑动
    pagination: {
      el: ".swiper-pagination",
      clickable: true,
    }
  });
}
// 使用URLSearchParams解析查询字符串
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
// 获取index参数的值
let currentIndex = urlParams.get('index')||1;
$('.content-wrapper .content').hide()
$(".content-wrapper .content").eq(currentIndex-1).show()
function initTab() {

  $(".header .header_li").eq(currentIndex-1).addClass('active')

  $(".header .header_li").on("click", function() {
    const targetIndex = $(this).attr("data-idx");
    if(currentIndex===targetIndex) return;
    // 找到 data-idx 等于 currentIndex 的元素
    const targetElement = $(`.header .header_li[data-idx="${currentIndex}"]`);
    targetElement.removeClass('active');
    $(".content-wrapper .content").eq(currentIndex-1).hide()
    $(".content-wrapper .content").eq(targetIndex-1).show()
    $(this).addClass('active')

    currentIndex = targetIndex
  })
}

initTab();
initSlider();




